-
Notifications
You must be signed in to change notification settings - Fork 118
Make local lambda server configurable #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bdadc76 to
67e3f3f
Compare
67e3f3f to
cb80b11
Compare
|
what is the status of this PR? It would be useful to have it... |
|
@pokryfka the work on this pr has stopped, since we chose to go a different route with configuring the LocalServer. Since the LocalServer is now automatically started if the ENV variable is set, we need to find a different way. One idea is to provide a bootstrap method like in swift-logging to configure the LocalServer before actual startup. Does this make sense? |
So the bootstrap function (static method) and public protocol LocalLambdaInvocationProxy {
// ...
}
public enum LocalLambda {
public static func bootstrap(_ proxyType: LocalLambdaInvocationProxy.Type) {
// ...
}
}Now Then if user wants to mock API Gateway he would need to import #if DEBUG
import AWSLambdaTesting
LocalLambda.bootstrap(APIGatewayV2Proxy.self)
#endif
// this will run LocalLambda.Server if DEBUG and LOCAL_LAMBDA_SERVER_ENABLED is "true"
Lambda.run(APIGatewayProxyLambda())@fabianfett is that what you had in mind? on top of that, it would probably be convenient to have a few proxies (API Gateway V1 and V2) defined (in |
|
I just noticed Perhaps one more advantage of the approach in the PR could be (a possibility of) an implementation of a public protocol LocalLambdaInvocationProxy {
init(eventLoop: EventLoop)
/// throws HTTPError
func invocation(from request: HTTPRequest) -> EventLoopFuture<ByteBuffer>
func processResult(_ result: ByteBuffer?) -> EventLoopFuture<HTTPResponse>
func processError(_ error: ByteBuffer?) -> EventLoopFuture<HTTPResponse>
} internal protocol LambdaServerBehavior {
func getInvocation() -> GetInvocationResult
func processResponse(requestId: String, response: String?) -> Result<Void, ProcessResponseError>
func processError(requestId: String, error: ErrorResponse) -> Result<Void, ProcessErrorError>
func processInitError(error: ErrorResponse) -> Result<Void, ProcessErrorError>
} |
I really like this approach. imo the priority is:
@pokryfka @fabianfett wdyt? |
|
@fabianfett what are your thoughts on that? I could help with that and:
|
|
@pokryfka I'd be excited if you could help out here. Go ahead! Maybe we should try to split the changes in small prs so we don't end up with such a big one like the one we have here. |
|
@fabianfett @tomerd please check the change on #138 |
|
@fabianfett could you please update this PR to be against the |
|
closing in inactive PRs, feel free to re-open if still relevant |
Motivation
We want to be able to mock different aws service behaviors with the
Lambda.LocalServer.Changes
Lambda.LocalServernow opens two ports: One for incoming requests (InvokeHandler) and one for the control plane API (ControlPlaneHandler)ServerState(please hand me ideas for better names) encapsulates all the "business" logic: Queueing incoming requests, ensuring control plane state, ...LocalLambdaInvocationProxyprotocol to mock the behavior of different aws servicesInvokeProxyis includedAWSLambdaTestingtarget, since we want to be able to access AWSLambdaEvents, if we implement anAPIGatewayV2Proxy